package junior.db.query;

public abstract class PageUtils {
	
	public static int countPages(long totalRecords, int limit) {
		return (int) totalRecords / limit + (totalRecords % limit > 0 ? 1 : 0);
	}
	
	public static int page2Start(int page, int limit) {
		return page * limit - limit;
	}

	public static int start2Page(int start, int limit) {
		if (limit > 0) return (int) (start + limit) / limit;
		return 1;
	}
	
}
